//
//  CJRewardVideoCustomEvent.m
//  CJMobileAdapter
//
//  Created by ly on 2024/3/1.
//

#import "CJRewardVideoCustomEvent.h"

@interface CJRewardVideoCustomEvent()

@property (nonatomic, assign) BOOL isFailed;

@end
@implementation CJRewardVideoCustomEvent

- (NSString *)networkUnitId {
    return self.serverInfo[@"unitid"];
}

- (void)rewardVideoAdDidLoad:(nonnull CJRewardVideoAd *)rewardAd resourceId:(nonnull NSString *)resourceId {
    [self trackRewardedVideoAdLoaded:rewardAd adExtra:nil];
}

- (void)rewardVideoAdLoadFailed:(nonnull CJRewardVideoAd *)rewardAd error:(nonnull NSError *)error {
    if (!_isFailed) {
        [self trackRewardedVideoAdLoadFailed:error];
        _isFailed = true;
    }
}

- (void)rewardVideoAdOnClicked:(nonnull CJRewardVideoAd *)rewardAd {
    [self trackRewardedVideoAdClick];
}

- (void)rewardVideoAdOnClosed:(nonnull CJRewardVideoAd *)rewardAd {
    [self trackRewardedVideoAdCloseRewarded:self.rewardGranted extra:@{}];
}

- (void)rewardVideoAdOnShow:(nonnull CJRewardVideoAd *)rewardAd {
    [self trackRewardedVideoAdShow];
    [self trackRewardedVideoAdVideoStart];
}

- (void)rewardVideoOnRewarded:(nonnull CJRewardVideoAd *)rewardAd requestId:(nonnull NSString *)requestId {
    [self trackRewardedVideoAdRewarded];
}

@end
